from api_post_class import *
import json
from sys import exit
from config import *
import time

if __name__ == "__main__":
    authType = 1
    operation = "BatchCalls"
    function = "createTask"
    taskName = str(time.time())
    workNumbers = "hhhlll2"
    preset_connection_rate = 1.0
    params = {
        "name": taskName,
        "workNumbers": workNumbers,
        "preset_connection_rate": preset_connection_rate,
    }
    f = ApiPost(auth_info, domain, version, "json")

    task_id = input("please input taskId:")
    batchId = input("please input batchId:")

    operation = "BatchCalls"
    function = "getBatchStatus"
    params = {
        "taskId": task_id,
        "batchId": batchId,
    }
    f.set_func_mode(operation, function, authType)
    rsp = f.post_info_to_api(params)
    print(rsp)
    rsp_dic = json.loads(rsp)
    try:
        if rsp_dic['resp']['respCode'] != 0:
            print("Error, please check and retry")
    except Exception as e:
        print(e)
